package com.juc.concurrency.jucExample.locksupport;

import java.util.concurrent.locks.LockSupport;

/**
 * @author huangweiyue
 * @description void park(Object blocker) 信息可以被记录到线程内部，所以推荐使用park(this)
 * 这样在打印线程堆栈排查问题的时候就能知道是哪个类被阻塞了
 * jps -l
 * jstack pid
 * 观察
 * LockSupport.park()  LockSupport.park(this)输出堆栈信息的区别
 * 发现 LockSupport.park(this)会打印出类的信息 见下方注释
 * @date Created in 2021-08-01
 */
public class LockSupportExample2 {
    public static void main(String[] args) {
        LockSupportExample2 lockSupportExample = new LockSupportExample2();
        lockSupportExample.testPark();
    }

    public void testPark() {
        // - parking to wait for  <0x000000076b9d6970> (a com.juc.concurrency.jucExample.locksupport.LockSupportExample2)
        LockSupport.park(this);
//        LockSupport.park();
    }
}
